package info.jbohn.view;

import info.jbohn.model.RSSMainModel;

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.JFrame;
import javax.swing.JSplitPane;

public class RSSMainUI extends JFrame implements ViewInterface
{
	RSSCenterUI centerUI = null;
	RSSLeftUI leftUI = null;
	private JSplitPane splitPane;
	
	public RSSMainUI() 
	{
		getContentPane().setLayout(new BorderLayout(0, 0));
		splitPane = new JSplitPane();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		leftUI = new RSSLeftUI();
		centerUI = new RSSCenterUI();
		this.add(splitPane);
		splitPane.setLeftComponent(leftUI);
		splitPane.setRightComponent(centerUI);
	}

	@Override
	public void displayUI() 
	{
		this.setVisible(true);		
	}

	@Override
	public void updateUI(RSSMainModel model) 
	{
		leftUI.updateUI(model);
		
	}
	
	public void updateCurrentRSS(RSSMainModel model, String current)
	{
		centerUI.setCurrentFeed(current);
		centerUI.updateUI(model);
	}
	
	public void updateCurrentRSSMessage(RSSMainModel model, int currentM)
	{
		centerUI.setCurrentFeed(currentM);
		centerUI.updateUI(model);
	}
	

	@Override
	public <T> void register(T list) {
		leftUI.register(list);
		centerUI.register(list);
	}

}
